﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using QuickGraph;
using RW.Data;
using RW.Data.Graph;
using RW.Data.Objects;
using RW.Parser;
using Action = RW.Data.Objects.Action;
using QuickGraph.Algorithms;
using RW.QueriesWindows;

namespace RW
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Query1Window query1Window;
        private Query2Window query2Window;
        private Query3Window query3Window;

        public MainWindow()
        {
            InitializeComponent();
            
            try
            {
                Problem problem = Parser.Parser.Parse("TEST.txt");

                Solver s = new Solver(problem);

                MultiGraph a = s.CreateMultiGraph();

                this.gl.Graph = new BidirectionalGraph<State, MultiGraphEdge>();
                this.gl.Graph.AddVertexRange(a.Vertices);
                this.gl.Graph.AddEdgeRange(a.Edges);

                query1Window = new Query1Window(problem, a);
                query2Window = new Query2Window(problem, a);
                query3Window = new Query3Window(problem, a);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void query1_Click(object sender, RoutedEventArgs e)
        {
            query1Window.Show();
        }

        private void query2_Click(object sender, RoutedEventArgs e)
        {
            query2Window.Show();
        }

        private void query3_Click(object sender, RoutedEventArgs e)
        {
            query3Window.Show();
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            query1Window.Close();
            query2Window.Close();
            query3Window.Close();
        }
    }
}
